import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from "@/components/layout/Layout";
import Login from "@/views/Login";

Vue.use(VueRouter);

const routes = [
	{
		path: '/login',
		name: 'login',
		meta: {
			requireAuth: false,
			title: '登陆'
		},
		component: Login
	},
	{
		path: '',
		name: 'layout',
		component: Layout,
		meta: {
			title: '运维管理系统'
		},
		children: [
			{
				path: '/',
				name: 'console',
				component: () => import('../views/Console'),
				meta: {
					title: '首页'
				}
			},
			{
				path: '/console',
				name: 'console',
				component: () => import('../views/Console'),
				meta: {
					title: '首页'
				}
			},
			{
				path: '/user/profile',
				name: 'profile',
				component: () => import('../views/user/UserDetail'),
				meta: {
					title: '用户信息'
				}
			},
			{
				path: '/user/operlog',
				name: 'operlog',
				component: () => import('../views/user/UserEventLog'),
				meta: {
					title: '用户操作日志'
				}
			},
			{
				path: '/property/entry/list',
				name: 'entryList',
				component: () => import('../views/property/EntryList'),
				meta: {
					title: '入库资产'
				}
			},
			{
				path: '/property/export/list',
				name: 'exportList',
				component: () => import('../views/property/ExportList'),
				meta: {
					title: '出库资产'
				}
			},
			{
				path: '/device/list',
				name: 'deviceList',
				component: () => import('../views/device/DeviceList')
			},
			{
				path: '/repair/list',
				name: 'repair',
				component: () => import('../views/repair/RepairRecordList'),
				meta: {
					title: '报修记录'
				}
			}
		]
	}
];

const router = new VueRouter({
	routes
});

router.afterEach((to, from) => {
	document.title = to.meta.title;
});

export default router
